package top.ztf.erp.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Range;
import top.ztf.erp.utils.BeanCopyUtil;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;


@Data
@AllArgsConstructor
@NoArgsConstructor
public class Permission implements Cloneable {

    public interface Add{}
    public interface Update{}

    @NotNull(groups = Update.class)
    private String id;//主键id

    @NotNull(groups = {Add.class,Update.class})
    @Pattern(regexp = "^[0-9]{1,8}$",message = "不合法,只允许输入,0-9的数字,至少一位,最多8位",groups = {Add.class,Update.class})
    private String code;// 权限码

    @NotNull(groups = {Add.class,Update.class})
    private String name;//权限名称

    private String moduleUrl;//权限url

    private String operationUrl;//操作的url

    @NotNull(groups = {Add.class,Update.class})
    @Range(min = 0,max = 999,message = "不合法,只允许输入1-3位数字",groups = {Add.class,Update.class})
    private Integer orderNo;//排序编号

    private String pid;//父id
    private String createTime;//创建的时间
    private String editTime;//修改的时间

    public  <T> T clone(Class<T> target)  {
        T t = null;
        try {
            t = target.newInstance();
            BeanCopyUtil.copy(this,t);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return t;
    }



}
